package java8NewFeatures.dateDomo;

import cn.hutool.core.date.DateUtil;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class test {
    public static void main(String[] args) {
            Calendar instance = Calendar.getInstance();
        List<Date> list = test.generateBeforeNDays(instance, 10);
        list.forEach(e->{
            System.out.println(DateUtil.format(e,"yyyy-MM-dd"));
        });
    }
    public static List<Date> generateBeforeNDays(Calendar cal, Integer n) {
        List<Date> list = new ArrayList<>();
        list.add(cal.getTime());
        for (int i = 1; i <n; i++) {
            cal.add(Calendar.DAY_OF_MONTH,-1);
            list.add(cal.getTime());
        }
        return list;
    }
}
